package com.hjimi.ski.utils;

import com.hjimi.ski.bean.DeviceMqttBean;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created By 孙岩
 * on 2024/6/21
 */
public class MqttJsonToBeanUtil {
    public static DeviceMqttBean setJsonToBean(String json){
        DeviceMqttBean bean = null;
        try {
            JSONObject obj = new JSONObject(json);
            bean = new DeviceMqttBean(
                    JsonParseUtil.getInt(obj,"code"),
                    JsonParseUtil.getInt(obj,"id"),
                    JsonParseUtil.getStr(obj,"url")
            );
            return bean;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
}
